package com.ruoyi.sea.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.sea.domain.SeaValueDay;
import com.ruoyi.sea.service.ISeaValueDayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 水质按日统计Controller
 * 
 * @author ruoyi
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/sea/day")
public class SeaValueDayController extends BaseController
{
    @Autowired
    private ISeaValueDayService seaValueDayService;


    @GetMapping("/list30")
    public AjaxResult selectSeaValueDay30(String code)
    {
        return success(seaValueDayService.selectSeaValueDay30(code));
    }

    /**
     * 查询按日统计列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SeaValueDay seaValueDay)
    {
        startPage();
        List<SeaValueDay> list = seaValueDayService.selectSeaValueDayList(seaValueDay);
        return getDataTable(list);
    }

    /**
     * 导出按日统计列表
     */
    @Log(title = "导出按日统计列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SeaValueDay seaValueDay)
    {
        List<SeaValueDay> list = seaValueDayService.selectSeaValueDayList(seaValueDay);
        ExcelUtil<SeaValueDay> util = new ExcelUtil<SeaValueDay>(SeaValueDay.class);
        util.exportExcel(response, list, "海洋按日统计数据");
    }

    /**
     * 获取按日统计详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(seaValueDayService.selectSeaValueDayById(id));
    }

    /**
     * 新增按日统计
     */
    @Log(title = "新增按日统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SeaValueDay seaValueDay)
    {
        return toAjax(seaValueDayService.insertSeaValueDay(seaValueDay));
    }

    /**
     * 修改按日统计
     */
    @Log(title = "修改按日统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SeaValueDay seaValueDay)
    {
        return toAjax(seaValueDayService.updateSeaValueDay(seaValueDay));
    }

    /**
     * 删除按日统计
     */
    @Log(title = "删除按日统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(seaValueDayService.deleteSeaValueDayByIds(ids));
    }
    /**
     * 查询最近7日统计列表
     */
    @GetMapping("/getLimit7")
    public AjaxResult selectSeaValueDaySeven(String code)
    {
        return success(seaValueDayService.selectSeaValueDaySeven(code));
    }
}
